package com.xinqi.common.web.config;

import com.xinqi.common.web.filter.RequestLoggingFilter;
import org.springframework.boot.autoconfigure.AutoConfiguration;
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.core.Ordered;

/**
 * 请求日志打印配置
 *
 * @author linkai
 * @date 2023/1/13
 */
@AutoConfiguration
@ConditionalOnWebApplication
public class RequestLogConfig {
    @Bean
    public FilterRegistrationBean<RequestLoggingFilter> logFilter() {
        FilterRegistrationBean<RequestLoggingFilter> filter = new FilterRegistrationBean<>(new RequestLoggingFilter());
        filter.setOrder(Ordered.HIGHEST_PRECEDENCE);
        return filter;
    }
}
